package com.th.aip.config;

import com.baidu.aip.ocr.AipOcr;
import com.th.aip.service.AipService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ErrorRua
 * @date 2023/06/24
 * @description:
 */
@Data
@Configuration
@EnableConfigurationProperties({AipConfigProperties.class})
@ConditionalOnClass(AipService.class)
public class AipConfig {
    @Autowired
    private AipConfigProperties aipConfigProperties;

    @Bean
    public AipOcr buildAipOcr() {
        return new AipOcr(aipConfigProperties.getAppID(),
                aipConfigProperties.getApiKey(),
                aipConfigProperties.getSecretKey());
    }
}
